package com.baibei.module;

import android.text.TextUtils;

/**
 * Created by shenminjie on 2017/12/8.
 * mail:shenminjie@100bei.com
 */

public class ImageUtils {

    /**
     * http://cbec-static.oss-cn-shenzhen.aliyuncs.com/trade/product/48a32422bad14efd81390f9820301029.jpg?x-oss-process=image/resize,m_mfit,h_500,w_500
     *
     * @param width  宽度
     * @param height 高度
     * @return 返回阿里适配的
     */
    public static String getImageUrlBySize(String url, int width, int height) {
        if (TextUtils.isEmpty(url)) {
            return null;
        }
        if (url.contains("?")) {
            int index = url.indexOf("?");
            url = url.substring(0, index);
            return url + "?x-oss-process=image/resize,m_mfit,h_" + height + ",w_" + width;
        }
        return url;
    }
}
